//
//  XLGHTTPProtocolBaseInternal.m
//  etionCBLogic
//
//  Created by chen on 14-2-14.
//  Copyright (c) 2014年 GuangZhouXuanWu. All rights reserved.
//

#import "HTTPProtocolBase.h"

#import "ProtocolHTTPSREST.h"

@implementation XLGHTTPProtocolBaseInternal

@synthesize URI = _URI;
@synthesize dicData = _dicData;
@synthesize HTTPMethod = _HTTPMethod;
@synthesize externRequestHead = _externRequestHead;
@synthesize requestID = _requestID;

-(id)init
{
    self = [super init];
    
    _transformType = EProtocolTransformTypeHTTPSREST;
    
    return self;
}

-(id)initWithProtocolType:(EProtocolTransformType)type
{
    self = [super init];
    
    _transformType = type;
    
    return self;
}

-(void)writeHTTPSREEST:(CProtocolHTTPSREST *)phr
{
    phr.URI = _URI;
    if (_HTTPMethod == XLGHTTPMethodTypeGet)
        phr.body = nil;
    else
        phr.body = [NSJSONSerialization dataWithJSONObject:_dicData!=nil?_dicData:[[NSDictionary new]autorelease_mm] options:0 error:nil];
    phr.HTTPRESTMethod = _HTTPMethod;
    
    if(_externRequestHead.count>0)
       [phr.requestHead setDictionary:_externRequestHead];
}

-(void)readHTTPSREEST:(CProtocolHTTPSREST *)phr output:(NSObject **)obj
{
    NSDictionary *dic = [super readHTTPSREEST:phr];
    (void)_requestID;
    (*obj) = dic;
}

-(void)dealloc
{
    [_requestID release_mm];
    [_URI release_mm];
    [_dicData release_mm];
    superdealloc_mm;
}

@end
